#include "pch.h"
#include <iostream>
#include <string>
#include <stdlib.h>
#include <typeinfo>
#include <math.h>

using namespace std;

class MyInteger
{
public:
	MyInteger(int = 1);
	int get() const;
	int addition(MyInteger&);
	int parseInt(const string&);
private:
	int value;
};

MyInteger::MyInteger(int TempValue)
{
	value = TempValue;
}

int MyInteger::get() const
{
	return this->value;
}

int MyInteger::addition(MyInteger& AddInt)
{
	return this->value + AddInt.value;
}

int MyInteger::parseInt(const string& str)
{
	int TempInt = 0;
	for (int i = 0;i < str.size();i++)
	{
		TempInt += (str[i] - 48)*pow(10, (str.size() - (i + 1)));
	}
	return TempInt;
}

int main()
{
	MyInteger a;
	MyInteger b(2);
	string num;
	cout << "value is " << a.get() << endl;
	cout << "addition return " << a.addition(b) << endl;
	cout << "please input number string!" << endl;
	cin >> num;
	cout << "num type is " << typeid(num).name() << endl;
	cout << "after switch type is " << typeid(a.parseInt(num)).name() << endl;
	cout << "int value is " << a.parseInt(num) << endl;
	return 0;
}